package com.day16.ex03;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMapDemo {
    public static void main(String[] args) {
        HashMap<String,Student>hm=new HashMap<String,Student>();
        Student s1=new Student("张三",18);
        Student s2=new Student("李四",19);
        Student s3=new Student("王五",20);
        hm.put("itheheima001",s1);
        hm.put("itheheima002",s2);
        hm.put("itheheima003",s3);
        Set<String> keySet=hm.keySet();
        for(String key:keySet){
            Student value=hm.get(key);
            System.out.println(key+":"+value.getName()+","+value.getAge());
        }
        System.out.println("-----------------------------------------");
        Set<Map.Entry<String,Student>>entrySet=hm.entrySet();
        for(Map.Entry<String,Student>me:entrySet){
            String key=me.getKey();
            Student value=me.getValue();
            System.out.println(key+":"+value.getName()+","+value.getAge());
        }
    }
}
